package com.macro.mall.remote;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.common.api.EsDocDto;
import com.macro.mall.common.api.EsIndexDto;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author：MinxiaoHao
 * @Description:
 * @name：EsDocRemote
 * @Date：2024/10/17 10:46
 */
@FeignClient("mall-es")
public interface EsProductRemote {
    /**
     * 批量添加
     * @param esDocDto 文档信息
     * @return 添加结果
     */
    @PostMapping("/doc/batchSave")
    public CommonResult batchSave(@Validated @RequestBody EsDocDto esDocDto);

    /**
     * 创建索引的接口
     * @param esIndexDto 索引信息
     * @return
     */
    @PostMapping("/index/create")
    public CommonResult createIndex(@Validated @RequestBody EsIndexDto esIndexDto);

    /**
     * 判断索引是否存在
     * @param indexName 索引名称
     * @return
     */
    @GetMapping("/index/exists")
    public CommonResult exists(@RequestParam @NotEmpty(message = "索引名称不能为空") String indexName);

}
